<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function fun1(){
				let xhr=new XMLHttpRequest()
				xhr.open("GET","info.txt",false)
				xhr.send()
				let data=xhr.responseText
				let spanElement = document.getElementById("y1");
                spanElement.style.color = "red";
                spanElement.innerHTML = data;
			}
			function fun2(){
				let xhr=new XMLHttpRequest()
				xhr.open("GET","info.txt",true)
				xhr.send()
				xhr.onreadystatechange=function(){
					if(xhr.readyState==4 && xhr.status==200){
						let data=xhr.responseText
						let spanElement = document.getElementById("y2");
						spanElement.style.color = "red";
						spanElement.innerHTML = data;
					}
				}
			}
		</script>
	</head>
	<body>
		点击按钮获得into.txt的文本数据（同步请求）<br>
		<button type="button" onclick="fun1()">获取信息</button><br>
		获得的信息：<span id="y1"></span><br>
		点击按钮获得into.txt的文本数据（异步请求）<br>
		<button type="button" onclick="fun2()">获取信息</button><br>
		获得的信息：<span id="y2"></span>
	</body>
</html>
